package com.xd.springboot.controller;

import com.xd.springboot.entity.JsonResult;
import com.xd.springboot.exception.BusinessErrorException;
import com.xd.springboot.exception.BusinessMsgEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/ex")
public class ExceptionController {

    private  static  final Logger log = LoggerFactory.getLogger(ExceptionController.class);

    @PostMapping("/test")
    public JsonResult test(@RequestParam("name") String name, @RequestParam("pass") String pass)
    {
        log.info("name:{}",name);
        log.info("pass:{}",pass);
        return new JsonResult();
    }

    @GetMapping("/business")
    public JsonResult testEx()
    {
        try {
            int i=1/0;
        } catch (Exception e){
            throw new BusinessErrorException(BusinessMsgEnum.UNEXPECTED_EXCEPTION);
        }

        return new JsonResult();
    }
}
